package edu.pku.sei.autounit.reflect.jdt;

import java.util.Map;

import edu.pku.sei.autounit.reflect.AbstractType;
import edu.pku.sei.autounit.reflect.Array;
import edu.pku.sei.autounit.reflect.Type;

public class JDTArray extends AbstractType implements Array{

	private Type metaType;
	private int dimensionality;
	
	protected JDTArray(Type type, int i) {
		this.metaType = type;
		this.dimensionality = i;
	}

	
	public String getName(Map<String, String> map) {
		StringBuffer sb = new StringBuffer();
		sb.append(metaType.getName(map));
		for(int i=0;i<dimensionality;i++){
			sb.append("[]");
		}
		return sb.toString();
	}

	
	public Type getElementType() {
		if(dimensionality>1)
			return new JDTArray(metaType,dimensionality-1);
		else
			return metaType;
	}

	
	public String getFullName() {
		StringBuffer sb = new StringBuffer();
		sb.append(metaType.getFullName());
		for(int i=0;i<dimensionality;i++){
			sb.append("[]");
		}
		return sb.toString();
	}
}
